﻿using MahApps.Metro.Controls;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace stringwpf
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : MetroWindow
    {
        public MainWindow()
        {
            this.InitializeComponent();
        }

        private void ThemeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void GenerateStringButton_Click(object sender, RoutedEventArgs e)
        {
            string s = "";

            string s1 = this.RichTextBox1.Text;
            string s2 = s1.Replace("\\", "\\\\");
            s2 = s2.Replace("\"", "\\\"");
            char[] split = new char[] { '\n' };
            string[] temp = s2.Split(split);

            if (this.ThemeComboBox.Text == "string_builder")
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i].Trim().Length > 2)
                    {
                        if (!temp[i].Trim().Substring(0, 2).Equals("//"))
                        {
                            s += "strTrans.Append(\"" + temp[i] + "\\n\");\n";
                        }
                        else
                        {
                            s += temp[i] + "\n";
                        }
                    }
                    else
                    {
                        s += "strTrans.Append(\"" + temp[i] + "\\n\");\n";
                    }
                }
            }
            else if (this.ThemeComboBox.Text == "+")
            {
                s += "strTrans=\"\";\n";
                for (int i = 0; i < temp.Length; i++)
                {
                    if (temp[i].Trim().Length > 2)
                    {
                        if (!temp[i].Trim().Substring(0, 2).Equals("//"))
                        {
                            s += "strTrans+=\"" + temp[i] + "\\n\";\n";
                        }
                        else
                        {
                            s += temp[i] + "\n";
                        }
                    }
                    else
                    {
                        s += "strTrans+=\"" + temp[i] + "\\n\";\n";
                    }
                }
            }

            this.RichTextBox2.Text = s;

        }

    }
}